<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');

//第三方认证失败
Route::get('/auth/callback', function (\Illuminate\Http\Request $request){
    if ($request->get('code')) {
    	
        return 'Login Success';
    } else {
        return 'Access Denied';
    }
}); 

    

//前端需要登录部分
Route::group(['namespace' => 'Example','as'=> 'home.'],function ($router) 
{ 	
	//测试
	Route::get('/test', 'TestController@test')->name('test');
	Route::get('/redis', 'IndexController@index')->name('redis');
	Route::get('/QrCode', 'TestController@QrCode')->name('QrCode');
	Route::get('/TestTrait', 'TestController@TestTrait')->name('TestTrait');
    Route::get('/testListenter', 'TestController@testListenter')->name('testListenter');
    Route::get('/sendemail', 'JobController@sendemail')->name('sendemail');
    Route::get('/encrypt', 'TestController@encrypt')->name('encrypt');
    Route::get('/oauth/auth/callback', 'OauthController@pass')->name('oauth.pass');
	    //第三方认证成功
	/*Route::get('oauth/auth/callback', function (\Illuminate\Http\Request $request){
	    if ($request->get('code')) {
	    	
	        return 'Login Success';
	    } else {
	        return 'Access Denied';
	    }
	});*/
});

//前端需要登录部分
Route::group(['namespace' => 'Home','middleware'=>['auth'],'as'=> 'home.'],function ($router) 
{ 	
	
    
});

//后台
Route::group(['prefix' => 'admin','namespace' => 'Admin'],function ($router) 
{ 	

    $router->get('login', 'LoginController@showLogin')->name('admin.login'); 
    $router->post('login', 'LoginController@login'); 
    $router->post('logout', 'LoginController@logout'); 
    $router->get('logout', 'LoginController@logout')->name('admin.logout');
});

Route::group(['prefix' => 'admin','namespace' => 'Admin','middleware'=>['auth.admin:admin','menu'],'as'=> 'admin.'],function ($router) 
{ 	
		//另一种写法
		//Route::post('role/destroyall', ['as' => 'role.destroy.all', 'uses' => 'RoleController@destroyall']);
		Route::get('/', ['as'=>'home', 'uses'=>'AdminController@index']);
	    Route::get('index', 'AdminController@index')->name('index');
	    //帐号
	    Route::get('user/index', 'AdminController@user')->name('user.index');
	    Route::get('user/create', 'AdminController@create')->name('user.create');
	    Route::post('user/store', 'AdminController@store')->name('user.store');
	    Route::get('user/edit/{id}', 'AdminController@edit')->name('user.edit');
	    Route::post('user/update', 'AdminController@update')->name('user.update');
	    Route::get('user/del/{id}', 'AdminController@del')->name('user.del');
	    //角色
	    Route::get('role/index', 'RoleController@index')->name('role.index');
	    Route::get('role/create', 'RoleController@create')->name('role.create');
	    Route::post('role/store', 'RoleController@store')->name('role.store');
	    Route::get('role/edit/{id}', 'RoleController@edit')->name('role.edit');
	    Route::post('role/update', 'RoleController@update')->name('role.update');
	    Route::get('role/del/{id}', 'RoleController@del')->name('role.del');
	    //权限规则
	    Route::get('permission/index', 'PermissionController@index')->name('permission.index');
	    Route::get('permission/create', 'PermissionController@create')->name('permission.create');
	    Route::post('permission/store', 'PermissionController@store')->name('permission.store');
	    Route::get('permission/edit/{id}', 'PermissionController@edit')->name('permission.edit');
	    Route::post('permission/update', 'PermissionController@update')->name('permission.update');
	    Route::get('permission/del/{id}', 'PermissionController@del')->name('permission.del');
});  